#!/usr/bin/perl 

package ApacheConfig;

sub new {
	my $class = shift;
	
	my $self = {
		_directives => {},
		_modules => (),
		_directories => (),
		_includes => (),
		_alias => {},
		_scriptalias => {},
		_errordocument=> {},
		_includefiles => (),
	};

	bless $self,$class;
	return $self;
}

sub addDirectoryName {
	my ($self,$dir)=@_;
	push(@{$self->{_directories}},$dir);
}

sub addModule {
	my ($self,$mod)=@_;
	push(@{$self->{_modules}},$mod);
}

sub addInclude {
	my ($self,$include)=@_;
	push(@{$self->{_includes}},$include);
}

sub addIncludeFile {
	my ($self,$file)=@_;
	push(@{$self->{_includedirs}},$file);
}

sub setAlias {
	my ($self,$alias,$dir) = @_;
	${$self->{_alias}}{$alias}=$dir;
}

sub setScriptAlias {
	my ($self,$alias,$dir) = @_;
	${$self->{_scriptalias}}{$alias}=$dir;
}

sub setErrorDocument {
	my ($self,$code,$response) = @_;
	${$self->{_errordocument}}{$code}=$response;
}

sub getErrorDocument {
	my ($self) = shift;
	return keys(%{$self->{_errordocument}});
}

sub getErrorDocumentValue {
	my ($self,$code)=@_;
	return ${$self->{_errordocument}}{$code};
}

sub getDirectories {
	my $self=shift;
	return @{$self->{_directories}};
}

sub getModules {
	my $self=shift;
	return @{$self->{_modules}};
}

sub getIncludes {
	my $self=shift;
	return @{$self->{_includes}};
}

sub getIncludeFiles {
	my $self=shift;
	return @{$self->{_includefiles}};
}

sub getAliases {
	my $self=shift;
	return keys(%{$self->{_alias}});
}

sub getAliasesDirs {
	my $self=shift;
	return values(%{$self->{_alias}});
}

sub getScriptAliases {
	my $self=shift;
	return keys(%{$self->{_scriptalias}});
}

sub getScriptAliasesDirs {
	my $self=shift;
	return values(%{$self->{_scriptalias}});
}

sub setDirective {
	my ($self,$key,$value) = @_;
	${$self->{_directives}}{$key}=$value;
}

sub getDirective {
	my ($self,$key)=@_;
	return ${$self->{_directives}}{$key};
}

1;
